2011-02-01 09:51:02 -06:00
|
|
|
//
|
|
|
|
// MGMTwitpicPostWindow.m
|
|
|
|
// CocoaShare
|
|
|
|
//
|
2011-02-02 14:58:24 -06:00
|
|
|
// Created by Mr. Gecko on 1/29/11.
|
2011-02-01 09:51:02 -06:00
|
|
|
// Copyright (c) 2011 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MGMTwitpicPostWindow.h"
|
|
|
|
#import "MGMAddons.h"
|
|
|
|
|
|
|
|
@implementation MGMTwitpicPostWindow
|
2011-02-12 09:17:28 -06:00
|
|
|
- (id)initWithContentRect:(NSRect)theRect styleMask:(NSUInteger)theStyleMask backing:(NSBackingStoreType)theBufferingType defer:(BOOL)isDefer {
|
|
|
|
if ((self = [super initWithContentRect:theRect styleMask:NSBorderlessWindowMask backing:theBufferingType defer:isDefer])) {
|
2011-02-01 09:51:02 -06:00
|
|
|
[self setLevel:NSStatusWindowLevel];
|
|
|
|
[self setAlphaValue:1.0];
|
|
|
|
[self setOpaque:NO];
|
|
|
|
[self setMovableByWindowBackground:YES];
|
|
|
|
forceDisplay = NO;
|
|
|
|
[self setBackgroundColor:[self whiteBackground]];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:self];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
- (void)dealloc {
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)windowDidResize:(NSNotification *)aNotification {
|
|
|
|
[self setBackgroundColor:[self whiteBackground]];
|
|
|
|
if (forceDisplay)
|
|
|
|
[self display];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFrame:(NSRect)frameRect display:(BOOL)displayFlag animate:(BOOL)animationFlag {
|
|
|
|
forceDisplay = YES;
|
|
|
|
[super setFrame:frameRect display:displayFlag animate:animationFlag];
|
|
|
|
forceDisplay = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSColor *)whiteBackground {
|
|
|
|
float alpha = 0.9;
|
|
|
|
NSImage *bg = [[NSImage alloc] initWithSize:[self frame].size];
|
|
|
|
[bg lockFocus];
|
|
|
|
|
|
|
|
float radius = 6.0;
|
|
|
|
float stroke = 3.0;
|
|
|
|
NSRect bgRect = NSMakeRect(stroke/2, stroke/2, [bg size].width-stroke, [bg size].height-stroke);
|
|
|
|
NSBezierPath *bgPath = [NSBezierPath pathWithRect:bgRect radiusX:radius radiusY:radius];
|
|
|
|
[bgPath setLineWidth:stroke];
|
|
|
|
|
|
|
|
[[NSColor colorWithCalibratedWhite:1.0 alpha:alpha] set];
|
|
|
|
[bgPath fill];
|
|
|
|
[[NSColor colorWithCalibratedWhite:0.6 alpha:alpha] set];
|
|
|
|
[bgPath stroke];
|
|
|
|
|
|
|
|
[bg unlockFocus];
|
|
|
|
|
|
|
|
return [NSColor colorWithPatternImage:[bg autorelease]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)canBecomeKeyWindow {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
@end
|