Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit eab7616ee63dff699160e23e77fa7b65e17b6748 @joericioppo committed Jan 10, 2011
@@ -0,0 +1,15 @@
+# Xcode
+build/*
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+xcuserdata
+profile
+*.moved-aside
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
@@ -0,0 +1,43 @@
+//
+// MyStyledView.h
+// MyStyledView
+//
+// Created by Joe Ricioppo on 1/9/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface MyStyledView : NSView {}
+
+@property (nonatomic, retain) NSGradient *gradient;
+@property (nonatomic, assign) CGFloat gradientAngle;
+@property (nonatomic, retain) NSGradient *inactiveGradient;
+
+@property (nonatomic, retain) NSColor *backgroundColor;
+@property (nonatomic, retain) NSColor *inactiveBackgroundColor;
+
+@property (nonatomic, copy) NSArray *backgroundImages; //three part image. (leftCap, middleFill, rightCap)
+@property (nonatomic, copy) NSArray *inactiveBackgroundImages; //three part image. (leftCap, middleFill, rightCap)
+
+@property (nonatomic, retain) NSColor *topEdgeColor;
+@property (nonatomic, retain) NSColor *topHighlightColor;
+@property (nonatomic, retain) NSColor *bottomHighlightColor;
+@property (nonatomic, retain) NSColor *bottomEdgeColor;
+
+@property (nonatomic, retain) NSGradient *rightEdgeGradient;
+@property (nonatomic, retain) NSGradient *leftEdgeGradient;
+
+@property (nonatomic, retain) NSShadow *innerShadow;
+@property (nonatomic, retain) NSShadow *innerGlow;
+
+// -------------- topEdge
+// -------------- topHighlight
+// ::::::::::::::
+// :::::::::::::: gradient/background
+// ::::::::::::::
+// -------------- bottomHighlight
+// -------------- bottomEdge
+
+@end
@@ -0,0 +1,145 @@
+//
+// MyStyledView.m
+// MyStyledView
+//
+// Created by Joe Ricioppo on 1/9/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "MyStyledView.h"
+//#import "NSGradient+Additions.h"
+#import "NSBezierPath+Additions.h"
+//#import "NSShadow+Additions.h"
+
+
+@implementation MyStyledView
+
+@synthesize gradient;
+@synthesize gradientAngle;
+@synthesize inactiveGradient;
+@synthesize backgroundColor;
+@synthesize inactiveBackgroundColor;
+@synthesize backgroundImages;
+@synthesize inactiveBackgroundImages;
+@synthesize topEdgeColor;
+@synthesize topHighlightColor;
+@synthesize bottomHighlightColor;
+@synthesize bottomEdgeColor;
+@synthesize rightEdgeGradient;
+@synthesize leftEdgeGradient;
+@synthesize innerShadow;
+@synthesize innerGlow;
+
+//- (id)initWithFrame:(NSRect)frame {
+//
+// self = [super initWithFrame:frame];
+// if (self) {
+// }
+// return self;
+//}
+
+- (void)drawRect:(NSRect)dirtyRect {
+
+ NSRect rect = self.bounds;
+ BOOL isKeyWindow = [[self window] isKeyWindow];
+
+ NSColor *backgroundColorToDraw = isKeyWindow ? self.backgroundColor : self.inactiveBackgroundColor ? : self.backgroundColor;
+ if (backgroundColorToDraw != nil) {
+ [backgroundColorToDraw set];
+ NSRectFill(rect);
+ }
+
+ NSGradient *gradientToDraw = isKeyWindow ? self.gradient : self.inactiveGradient ? self.inactiveGradient : self.gradient; //hrm
+ if (gradientToDraw) {
+ [gradientToDraw drawInRect:rect angle:self.gradientAngle ? : self.isFlipped ? 90 : -90];
+ }
+
+ NSArray *backgroundImagesToDraw = isKeyWindow ? self.backgroundImages : self.inactiveBackgroundImages ? : self.backgroundImages;
+ if (backgroundImagesToDraw.count == 3) {
+
+ __block BOOL shouldDrawThreePartImage = NO;
+ [self.backgroundImages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ if ([obj isKindOfClass:[NSImage class]]) {
+ shouldDrawThreePartImage = YES;
+ } else {
+ shouldDrawThreePartImage = NO;
+ *stop = YES;
+ }
+
+ }];
+
+ if (shouldDrawThreePartImage) {
+ NSImage *leftCap = [self.backgroundImages objectAtIndex:0];
+ NSImage *middleFill = [self.backgroundImages objectAtIndex:1];
+ NSImage *rightCap = [self.backgroundImages objectAtIndex:2];
+ NSDrawThreePartImage(rect, leftCap, middleFill, rightCap,
+ NO, NSCompositeSourceOver, 1.0, self.isFlipped);
+ }
+ }
+
+ if (self.innerShadow) {
+ NSBezierPath *innerShadowPath = [NSBezierPath bezierPathWithRect:rect];
+ [innerShadowPath fillWithInnerShadow:self.innerShadow];
+ }
+
+ if (self.innerGlow) {
+ NSBezierPath *innerGlowPath = [NSBezierPath bezierPathWithRect:rect];
+ [innerGlowPath fillWithInnerShadow:self.innerGlow];
+ }
+
+ if (self.topEdgeColor) {
+ NSBezierPath *topHighlightPath = [NSBezierPath bezierPath];
+ [topHighlightPath setLineWidth:0.0];
+ [topHighlightPath moveToPoint:NSPointFromCGPoint(CGPointMake(rect.origin.x, NSMaxY(rect) -0.5))];
+ [topHighlightPath lineToPoint:NSPointFromCGPoint(CGPointMake(NSMaxX(rect), NSMaxY(rect) -0.5))];
+ [topHighlightPath closePath];
+
+ [self.topEdgeColor set];
+ [topHighlightPath stroke];
+ }
+
+ if (self.topHighlightColor) {
+ NSBezierPath *topHighlightPath = [NSBezierPath bezierPath];
+ [topHighlightPath setLineWidth:0.0];
+ [topHighlightPath moveToPoint:NSPointFromCGPoint(CGPointMake(rect.origin.x, NSMaxY(rect) -1.5))];
+ [topHighlightPath lineToPoint:NSPointFromCGPoint(CGPointMake(NSMaxX(rect), NSMaxY(rect) -1.5))];
+ [topHighlightPath closePath];
+
+ [self.topHighlightColor set];
+ [topHighlightPath stroke];
+ }
+
+ if (self.bottomHighlightColor) {
+ NSBezierPath *bottomHighlightPath = [NSBezierPath bezierPath];
+ [bottomHighlightPath setLineWidth:1.0];
+ [bottomHighlightPath moveToPoint:NSPointFromCGPoint(CGPointMake(rect.origin.x, rect.origin.y + 1.5))];
+ [bottomHighlightPath lineToPoint:NSPointFromCGPoint(CGPointMake(NSMaxX(rect), rect.origin.y + 1.5))];
+ [bottomHighlightPath closePath];
+
+ [self.bottomHighlightColor set];
+ [bottomHighlightPath stroke];
+ }
+
+ if (self.bottomEdgeColor) {
+ NSBezierPath *bottomEdgePath = [NSBezierPath bezierPath];
+ [bottomEdgePath setLineWidth:1.0];
+ [bottomEdgePath moveToPoint:NSPointFromCGPoint(CGPointMake(rect.origin.x, rect.origin.y + 0.5))];
+ [bottomEdgePath lineToPoint:NSPointFromCGPoint(CGPointMake(NSMaxX(rect), rect.origin.y + 0.5))];
+ [bottomEdgePath closePath];
+
+ [self.bottomEdgeColor set];
+ [bottomEdgePath stroke];
+ }
+
+ if (self.rightEdgeGradient) {
+ NSRect edgeRect = NSMakeRect((NSMaxX(rect) - 1.5), 0.0, 1.0, NSMaxY(rect));
+ [self.rightEdgeGradient drawInRect:edgeRect angle:self.isFlipped ? 90 : -90];
+ }
+
+ if (self.leftEdgeGradient) {
+ NSRect edgeRect = NSMakeRect(0.0, 0.0, 1.0, NSMaxY(rect));
+ [self.leftEdgeGradient drawInRect:edgeRect angle:self.isFlipped ? 90 : -90];
+ }
+}
+
+@end
Oops, something went wrong.

0 comments on commit eab7616

Please sign in to comment.