macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

drawBackgroundForGlyphRange:atPoint:

グリフの範囲のバックグラウンドを描画します
-(void)drawBackgroundForGlyphRange:(NSRange)glyphRange:
          atPoint:(NSPoint)containerOrigin:

解説

グリフの範囲(glyphRange)で指定された範囲(一つのNSTextContainerに格納されている)のバックグラウンドを描画します。
containerOriginは描画されるNSViewの座標系で表されたNSTextContainerの位置。
このメソッドは対象となるNSViewにフォーカスした状態で呼び出す必要があります。
必要な場合にグリフの生成やレイアウトが実行されます。

返り値

( void )

なし

引数

( NSRange )glyphRange
( NSPoint )containerOrigin

フレームワーク

ApplicationKit

クラス

NSLayoutManager

Instance Methods

使用可能

10.0

参照

- drawGlyphsForGlyphRange:atPoint:
- glyphRangeForTextContainer:
- textContainerOrigin (NSTextView)

例文

NSLayoutManager *layM;
layM = [myOutlet layoutManager];

[myOutlet setBackgroundColor: [NSColor redColor]];

[layM drawBackgroundForGlyphRange:NSMakeRange(2,3)  atPoint:NSMakePoint(3,5)];

[[sender window] display];
//NSLog([NSString stringWithFormat:@"%@",[dic description]]);
//NSLog([NSString stringWithFormat:@"range %d-%d",range.location,range.length]);


//*******************************
- (void)drawBackgroundForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin
{

	//描画に回転をかける
	
	NSGraphicsContext *context = [NSGraphicsContext currentContext];
	[context saveGraphicsState];
	
	
	NSAffineTransform* affine = [NSAffineTransform transform];
	// move axis
	[affine translateXBy: 0 //currentPoint.x + attrSize.width/2
					 yBy: -5 ];//currentPoint.y + attrSize.height/2 ]; // Someone modifies here properly please.

	[affine rotateByDegrees:10.0];
	[affine concat];	
	
		
				
				
	//NSPoint newPoint = NSMakePoint(origin.x,origin.y);//y
	//NSSize newSize = NSMakeSize(printingAdjustment.width,printingAdjustment.height+100);
	//NSLog(NSLocalizedString( @"LM00004", @""),point.x,point.y);

	[super drawBackgroundForGlyphRange:glyphsToShow atPoint:origin];
	
	////描画に回転をかける
	[context restoreGraphicsState];
	
}