// // SFMiniControls.m // ShinyRuler // // Created by Matteo rattotti on 12/20/07. // Copyright 2007 www.shinyfrog.net. All rights reserved. // #import "SFMiniControls.h" #import "SFRulerView.h" @implementation SFMiniControls - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code here. } return self; } - (void)drawRect:(NSRect)rect { [[NSColor blueColor] set]; NSRectFill(rect); } // We don't want to drag the window around - (BOOL)mouseDownCanMoveWindow{ return NO; } // We flip the view because we need to match the window coordinate - (BOOL)isFlipped{ return YES; } - (void)mouseDragged:(NSEvent *)theEvent { //NSRect resizeSpace = NSMakeRect([self frame].size.width -20.0, 0, 20.0, [self frame].size.height); //NSLog(@"balozzo %f %f %f %f", resizeSpace.origin.y, resizeSpace.origin.x, resizeSpace.size.height, resizeSpace.size.width); NSPoint wPoint = [self convertPoint:[theEvent locationInWindow] fromView: [self superview]]; NSPoint tempPoint = [self convertPoint:[theEvent locationInWindow] fromView: nil]; NSLog(@"point %f %f", tempPoint.x, tempPoint.y); NSLog(@"DRAAAAG %f %f", wPoint.x, wPoint.y); /*if(wPoint.x > [[self window] frame].size.width){ NSLog(@"need to resize!!"); NSRect newFrame = [[self window] frame]; newFrame.size.width = wPoint.x; newFrame.size.height = wPoint.x; //newFrame.origin.y = 300.0 - (wPoint.x - [[self window] frame].size.width); [[self window] setFrame:newFrame display:YES]; //[[self window] setContentSize:NSMakeSize(wPoint.x, wPoint.x)]; }*/ /*if(wPoint.x > [[self superview]frame].size.width){ NSLog(@"urge to resize"); }*/ if([(SFRulerView*)[self superview] isOrizontal]) [[self superview] setFrameSize:NSMakeSize([[self superview]frame].size.width + wPoint.x, [[self superview]frame].size.height)]; else{ wPoint = [self convertPoint:[theEvent locationInWindow] fromView: [[self window]contentView]]; NSLog(@"D %f %f", wPoint.x, wPoint.y); } /*if(wPoint.x < [[self window] frame].size.width){ NSRect newFrame = [[self window] frame]; newFrame.size.width = wPoint.x; newFrame.size.height = wPoint.x; [[self window] setFrame:newFrame display:YES]; }*/ /*if(NSPointInRect(tempPoint, resizeSpace)){ //[[self window] setMovableByWindowBackground:NO]; } else{ }*/ } @end