#import "fontView.h" @implementation fontView - (id)initWithFrame:(NSRect)frameRect { if ((self = [super initWithFrame:frameRect]) != nil) { allFonts = [[[NSFontManager sharedFontManager] availableFonts] retain]; //NSLog(@"font -> %@", allFonts); size = 12; } return self; } - (void)drawRect:(NSRect)rect { unsigned fontCounter = [allFonts count]; NSMutableDictionary *d = [NSMutableDictionary dictionary]; [[NSColor whiteColor] set]; [NSBezierPath fillRect:[self bounds]]; //NSAttributedString *stronga = [[NSAttributedString alloc] initWithString:@"merda" attributes:d]; int i = 0; for (i; i < fontCounter; ++i) { [d setObject:[NSFont fontWithName:[allFonts objectAtIndex:i] size:size] forKey:NSFontAttributeName]; //NSLog(@"%@",[allFonts objectAtIndex:i]); NSPoint p = NSMakePoint(20, i * (size + 10)); //NSLog(@"point %f", p.x); //NSLog(@"point %f", p.y); //[self setFrame:NSMakeRect(10,10, 1800, 500)]; //[self setBounds:NSMakeRect(0,0,1000, 1000)]; NSString *str = @"The quick brown fox jumps over the lazy dog"; [str drawAtPoint:p withAttributes:d]; } [self setFrame:NSMakeRect(10,10, 500, i*(size + 10))]; } - (void) mouseDown: (NSEvent *) event { // deal in window coordinates. there is a scrolling problem // if using view coordinates because view coordinates // can get transformed grabOrigin = [event locationInWindow]; NSClipView *contentView; contentView = (NSClipView*)[self superview]; //NSLog(@"asd -> %@", [self superview]); scrollOrigin = [contentView bounds].origin; } // mouseDown - (void) mouseDragged: (NSEvent *) event { NSPoint mousePoint; mousePoint = [event locationInWindow]; float deltaX, deltaY; deltaX = grabOrigin.x - mousePoint.x; deltaY = mousePoint.y - grabOrigin.y; NSPoint newOrigin; newOrigin = NSMakePoint (scrollOrigin.x + deltaX, scrollOrigin.y - deltaY); [self scrollPoint: newOrigin]; } // mouseDragged @end