I am creating an application (desktop) that is an ad layout manager. The dimensions from the Indesign template I'm working with are in inches. For example, a magazine measuring 8x10.5 inches. Therefore, to give the user an idea of ββthe mag page, I place the NSScrollView in the main window and use the conversion 72 (pixels per inch) and then display the ruler, for example:
displayPageRect=NSMakeRect(400.0, 70.0,72*8.125,72*10.5); displayPage = [[NSScrollView alloc] initWithFrame:displayPageRect]; //set up the rulers display [displayPage setRulersVisible:YES]; [displayPage setHasVerticalRuler:YES]; [displayPage setHasHorizontalRuler:YES]; //set up border color and width [displayPage setBorderType:NSLineBorder]; //display the displayPage on the screen [[mainWin contentView] addSubview:displayPage];
this works great, but the rulers come out in inches and are a bit bitten.

Also, note that there is a purple rectangle in the image that starts from the top of the screen and is out of center on the screen. This is an NSScroll routine and is supposed to represent page fields. This does not work either.
//make a new page element for page borders PageElements* pageBorders = [PageElements new]; NSColor* borderColor = [NSColor purpleColor]; [pageBorders setColor:borderColor]; [pageBorders initWithFrame:NSMakeRect(72*.313, 72*.375, 72*7.499, 72*9.875)]; [[displayPage contentView] addSubview:pageBorders];
Obviously I'm doing something wrong in my conversions / placements. Can someone correct me on this? In addition, is there anyway to get the 0,0 ruler of the ruler with x = 0, y = 0, the coordinates of the form?
source share