Created
November 25, 2010 20:55
-
-
Save visigoth/715903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface HostView : NSView { | |
| NSView *_docView; | |
| CGFloat _scale; | |
| } | |
| @property (assign) CGFloat scale; | |
| @end | |
| @implementation HostView | |
| @synthesize scale=_scale; | |
| - (void)updateFrame { | |
| NSRect frame = _docView.frame; | |
| frame.size.width = frame.size.width * _scale; | |
| frame.size.height = frame.size.height * _scale; | |
| self.frame = frame; | |
| } | |
| - (void)setScale:(CGFloat)f { | |
| _scale = f; | |
| [docView scaleUnitSquareToSize:NSMakeSize(_scale, _scale)]; | |
| [self updateFrame]; | |
| } | |
| - (void)documentFrameChanged:(NSNotification *)n { | |
| [self updateFrame]; | |
| } | |
| - (void)initWithDocumentView:(NSView *)docView { | |
| _scale = 1.0; | |
| _docView = [docView retain]; | |
| [self addSubview:_docView]; | |
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentFrameChanged:) name:NSViewFrameDidChangeNotification object:_docView]; | |
| [self updateFrame]; | |
| } | |
| - (void)dealloc { | |
| [_docView release]; | |
| [super dealloc]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment