Hi
I have a custom view, which contains a number of subviews, where it is much
more intuitive to the user if items appear from the upper left corner than the
bottom left corner. Normally, I would just flip the view and the placement of
subviews is what I expect. When I apply a scaled affine transform to the
subviews however, poof. The subviews vanish and no amount of resizing the
window makes them reappear.
Here's a simple example of what I'm doing
Containing view:
- (BOOL) isFlipped { return YES; }
- (id) initWithFrame:(NSRect) inFrame
{
self = [super initWithFrame: inFrame];
if (self)
{
NSRect *subFrame =
NSMakeRect(10, 10, 500, 1000);
MySubView *subview =
[[MySubView alloc] initWithFrame: subFrame];
NSAffineTransform *subTransform = [[NSAffineTransform
transform] retain];
float vertPadding
= 20;
[transform scaleBy: (inFrame.size.height - vertPadding) /
subFrame.size.height];
[self addSubview: subview];
}
return self;
}
- (void) drawRect:(NSRect) inDirtyRect
{
[[NSColor blackColor] set];
NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}
- (NSAffineTransform *) subTransform
{
return subTransform;
}
MySubView
- (void) drawRect:(NSRect) inDirtyRect
{
[[[self superview] subTransform] concat];
[[NSColor greenColor] set];
NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}
What do I need to do to scale a subview using an NSAffineTransform and have
it's upper left stay put? Or at least not move it off into the aether?
Thanks for any help._______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]