refreshing after a zooming an nstextview
refreshing after a zooming an nstextview
- Subject: refreshing after a zooming an nstextview
- From: Matthew Weinstein <email@hidden>
- Date: Sun, 1 May 2005 11:19:09 -0400
Dear cocoa-nuts,
After searching a while I found code to help zoom a text view. I do it
as shown below. It does work; the text zooms. But the
nstextview/scrollview doesn't adjust the rows at that point. How do I
tell it to recalculate and redraw everything. I've tried a number of
notifications and calls, but none seem to take. 1000 thanks in advance.
Here are the notifications I post:
[self setZoom: [gPrefBoss zoomWindowFactor]];
[[NSNotificationCenter defaultCenter] postNotification:
[NSNotification notificationWithName:
@"NSTextViewDidChangeTypingAttributesNotification" object: theDoc]];
[[NSNotificationCenter defaultCenter] postNotification:
[NSNotification notificationWithName: @"NSWindowDidResizeNotification"
object: myWindow]];
Here is my implementation of zoom:
@implementation NSView (ScaleUtilities)
const NSSize unitSize = { 1.0, 1.0 };
// This method makes the scaling of the receiver equal to the window's
// base coordinate system.
- (void) resetScaling { [self scaleUnitSquareToSize: [self convertSize:
unitSize fromView: nil]]; }
// This method sets the scale in absolute terms.
- (void) setScale:(NSSize) newScale
{
[self resetScaling]; // First, match our scaling to the window's
coordinate system
[self scaleUnitSquareToSize:newScale]; // Then, set the scale.
}
// This method returns the scale of the receiver's coordinate system,
relative to
// the window's base coordinate system.
- (NSSize) scale { return [self convertSize:unitSize toView:nil]; }
// Use these if you'd rather work with percentages.
- (float) scalePercent { return [self scale].width * 100; }
- (void) setScalePercent:(float) scale
{
scale = scale/100.0;
[self setScale:NSMakeSize(scale, scale)];
[self setNeedsDisplay:YES];
}
@end
Matthew Weinstein
Associate Professor of Science Education
Kent State University
404 J White Hall
Kent, OH 44242
email@hidden
330 672-0653
_______________________________________________
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