0

I have a simple custom view in my Mac OS X application that is essentially empty. Here is the code:

@implementation MyDrawingView

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

    return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
    NSLog(@"bounds:x:%f y:%f w:%f h:%f", self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height);
}

@end

Here is the output of NSLog:

bounds:x:0.000000 y:0.000000 w:713.000000 h:509.000000

I read about user space here: Coordinate Systems and Transforms

Does this mean that my view is going to show 713/72 inches wide on screen? It doesn't show up that wide in reality. I have a background color set on my view so I can see it just as wide as it really is.

AmaltasCoder
  • 1,123
  • 3
  • 17
  • 35

1 Answers1

1

the view is 713 points wide. 713*screenscale = pixel size which you can then use with dpi to get the inches shown ;)

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • a)Where do you get screenscale from and b)what does it mean to say that user space is fixed 72points/inch? – AmaltasCoder Feb 21 '15 at 06:54
  • a) on osx you get the scale for your processnfrom your NSWindow's backingScale property – Daij-Djan Feb 21 '15 at 09:38
  • b) thats what you said "713/72 inches wide on screen?" -- I therefore assumed that you knew you had a display with 72dpi (if you don't have the dpi. use http://stackoverflow.com/questions/12589198/how-to-read-the-physical-screen-size-of-osx) – Daij-Djan Feb 21 '15 at 09:39