/* # Created by Matteo Rattotti on 13/03/06. # Copyright (c) 2006 - 2007 Shiny Frog. All rights reserved. # Contact matteo.rattotti@shinyfrog.net for any problem # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #import "GBoxView.h" #import "img2icsnController.h" @implementation GBoxView // Dragging Things - (void)awakeFromNib{ [self addCloseButton]; [self addMiniaturizeButton]; [self addPathButton]; } // Drawing things - (void)drawRect:(NSRect)rect { float borderWidth = 2.0; NSColor *bgColor = [NSColor colorWithCalibratedWhite:0.90 alpha:1]; //NSColor *bgColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.35]; //NSRect bgRect = rect; NSRect boxRect = [self bounds]; NSRect bgRect = boxRect; bgRect = NSInsetRect(boxRect, borderWidth / 2.0, borderWidth / 2.0); bgRect = NSIntegralRect(bgRect); bgRect.origin.x += 0.5; bgRect.origin.y += 0.5; int minX = NSMinX(bgRect); int midX = NSMidX(bgRect); int maxX = NSMaxX(bgRect); int minY = NSMinY(bgRect); int midY = NSMidY(bgRect); int maxY = NSMaxY(bgRect); float radius = 25.0; // correct value to duplicate Panther's App Switcher NSBezierPath *bgPath = [NSBezierPath bezierPath]; // Bottom edge and bottom-right curve [bgPath moveToPoint:NSMakePoint(midX, minY)]; [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, minY) toPoint:NSMakePoint(maxX, midY) radius:radius]; // Right edge and top-right curve [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, maxY) toPoint:NSMakePoint(midX, maxY) radius:radius]; // Top edge and top-left curve [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(minX, maxY) toPoint:NSMakePoint(minX, midY) radius:radius]; // Left edge and bottom-left curve [bgPath appendBezierPathWithArcFromPoint:bgRect.origin toPoint:NSMakePoint(midX, minY) radius:radius]; [bgPath closePath]; [bgColor set]; [bgPath fill]; NSColor *bColor = [NSColor grayColor]; [bColor set]; [bgPath setLineWidth:borderWidth]; [bgPath stroke]; } - (void)addCloseButton { NSButton *closeButton = [[NSButton alloc] initWithFrame:NSMakeRect(15.0, [self frame].size.height - 30.0, 18.0, 18.0)]; [self addSubview:closeButton]; [closeButton setBezelStyle:NSRoundedBezelStyle]; [closeButton setButtonType:NSMomentaryChangeButton]; [closeButton setBordered:NO]; [closeButton setImage:[NSImage imageNamed:@"buttClose"]]; [closeButton setTitle:@""]; [closeButton setImagePosition:NSImageBelow]; [closeButton setTarget:self]; [closeButton setFocusRingType:NSFocusRingTypeNone]; [closeButton setAction:@selector(buttonCloseHit:)]; [closeButton release]; } - (void)addMiniaturizeButton { NSButton *minButton = [[NSButton alloc] initWithFrame:NSMakeRect(38.0, [self frame].size.height - 30.0, 18.0, 18.0)]; [self addSubview:minButton]; [minButton setBezelStyle:NSRoundedBezelStyle]; [minButton setButtonType:NSMomentaryChangeButton]; [minButton setBordered:NO]; [minButton setImage:[NSImage imageNamed:@"buttMinimize"]]; [minButton setTitle:@""]; [minButton setImagePosition:NSImageBelow]; [minButton setTarget:self]; [minButton setFocusRingType:NSFocusRingTypeNone]; [minButton setAction:@selector(buttonMinHit:)]; [minButton release]; } - (void)addPathButton { NSButton *pathButton = [[NSButton alloc] initWithFrame:NSMakeRect(31.0, 42.0, 18.0, 18.0)]; [self addSubview:pathButton]; [pathButton setBezelStyle:NSRoundedBezelStyle]; [pathButton setButtonType:NSMomentaryChangeButton]; [pathButton setBordered:NO]; [pathButton setImage:[NSImage imageNamed:@"goTo"]]; [pathButton setTitle:@""]; [pathButton setImagePosition:NSImageBelow]; [pathButton setTarget:self]; [pathButton setFocusRingType:NSFocusRingTypeNone]; [pathButton setAction:@selector(buttonPathHit:)]; [pathButton release]; } - (void)buttonCloseHit:(id)sender{ [[self window]close]; } - (void)buttonMinHit:(id)sender{ [[self window]miniaturize:self]; } - (void)buttonPathHit:(id)sender{ [[NSApp delegate] changeExpPath:self]; //[[self window]miniaturize:self]; } @end