Scaling view and draw one pixel line
Scaling view and draw one pixel line
- Subject: Scaling view and draw one pixel line
- From: Lorenzo <email@hidden>
- Date: Sun, 24 Sep 2006 17:39:43 +0200
Hi,
I need to scale my view horizontally only and I want that a rectangle inside
this view still looks with a "one pixel width" border. It almost work well,
but sometimes I cannot see the border. What do I miss?
When I change the scaleFactor I do:
------------------------------------------------------
scaleFactor = [sender floatValue];
oneSize = NSMakeSize(1.0, 1.0);
oldSize = [aView convertSize:oneSize fromView:[aView superview]];
newSize = NSMakeSize(oldSize.width / scaleFactor, 1.0);
[aView scaleUnitSquareToSize:newSize];
frameSize = NSMakeSize(gWidth / scaleFactor, [aView frame].size.height)
[aView setFrameSize:frameSize];
[aView setNeedsDisplay:YES];
In the drawRect method of the rectangle subview I do:
------------------------------------------------------
// I fill the rectangle with blue
NSRect theBounds = [self bounds];
[[NSColor blueColor] set];
NSRectFill(theBounds);
// So I fill the insect rectangle with white
[[NSColor whiteColor] set];
NSRectFill(NSInsetRect(theBounds, 1.0f * scaleFactor, 1.0f));
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden