• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Printing images always puts image in corner...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing images always puts image in corner...


  • Subject: Printing images always puts image in corner...
  • From: Jiva DeVoe <email@hidden>
  • Date: Mon, 29 Jul 2002 23:41:03 -0700

I have a document based application. In that document, I have a button,
which ties to the following event:

-(IBAction)printClicked:(id)sender
{
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
NSPrintOperation *printOp;
TestView *testView = [[TestView alloc] initWithPrintInfo:printInfo];
printOp = [NSPrintOperation printOperationWithView:testView
printInfo:printInfo];
[printOp setShowPanels:YES];
[printOp runOperation];

}

This, as you can see, creates a TestView object, and uses it to print.
TestView is a custom NSView inherited object. It's code is below.
Specifically, the problem is, no matter where I set my point in the drawRect
function, ALL my images I ever draw wind up in the lower left corner of my
page!!! What gives????!? HELP! I have been working on this problem for 2
weeks and it's killing me!

Here's the custom view module...

#import "TestView.h"


@implementation TestView

-(id)initWithPrintInfo:(NSPrintInfo *)printInfo
{

NSRect theFrame;
NSSize paperSize;

pages = 1;

paperSize = [printInfo paperSize];
theFrame.origin = NSMakePoint(0, 0);
theFrame.size.width = paperSize.width;
theFrame.size.height = paperSize.height * pages;

rectHeight = paperSize.height;

NSLog(@"%f - %f %f - %f", theFrame.size.width, theFrame.size.height,
theFrame.origin.x, theFrame.origin.y);
self = [super initWithFrame:theFrame];
return self;
}

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}

- (void)drawRect:(NSRect)rect
{
// Drawing code here.
NSPoint picturePoint = NSMakePoint(500, 500);

NSImage *pic = [[NSImage alloc] initWithContentsOfFile:[[NSBundle
mainBundle] pathForImageResource:@"headshot_small.jpg"]];
NSLog(@"Point: %f, %f", picturePoint.x, picturePoint.y);
[pic compositeToPoint:picturePoint operation:NSCompositeSourceAtop];
}

-(BOOL)knowsPageRange:(NSRangePointer)range
{
range->location = 1;
range->length = pages;
return YES;
}

-(NSRect)rectForPage:(int)pageNum
{
NSRect rect;

rect.size.width = [self bounds].size.width;
rect.size.height = rectHeight;
rect.origin.x = [self bounds].origin.x;
rect.origin.y = NSMaxY([self bounds]) - (pageNum * rect.size.height);
NSLog(@"%f - %f %f - %f", rect.size.width, rect.size.height,
rect.origin.x, rect.origin.y);
return rect;

}

@end


And it's header:

#import <AppKit/AppKit.h>


@interface TestView : NSView
{
int pages;
float rectHeight;
}
-(id)initWithFrame:(NSRect)frame;
-(BOOL)knowsPageRange:(NSRangePointer)range;
-(NSRect)rectForPage:(int)pageNum;
-(id)initWithPrintInfo:(NSPrintInfo *)printInfo;
- (void)drawRect:(NSRect)rect ;

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re[THE FIX]: _assign__t18string_char_traits1ZcRcRCc link undefined sym?
  • Next by Date: Re: Knowing when window closed
  • Previous by thread: Re: customized the about box
  • Next by thread: maximize and new
  • Index(es):
    • Date
    • Thread