mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-06-09 13:29:31 +00:00
update views
git-svn-id: svn://qnap.local/TwoTerm/branches/frameless@2463 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
eede1abbca
commit
35094617f6
|
@ -102,5 +102,6 @@
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
[_color release];
|
[_color release];
|
||||||
|
[super dealloc];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -10,17 +10,21 @@
|
||||||
|
|
||||||
@interface TitleBarView : NSView
|
@interface TitleBarView : NSView
|
||||||
{
|
{
|
||||||
NSColor *_color;
|
NSColor *_backgroundColor;
|
||||||
NSTextField *_label;
|
NSTextField *_label;
|
||||||
NSImage *_rightImage;
|
NSImage *_rightImage;
|
||||||
NSImage *_leftImage;
|
NSImage *_leftImage;
|
||||||
NSImage *_centerImage;
|
NSImage *_centerImage;
|
||||||
|
|
||||||
|
BOOL _dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, retain) NSColor *color;
|
@property (nonatomic, retain) NSColor *backgroundColor;
|
||||||
@property (nonatomic, retain) IBOutlet NSTextField *label;
|
@property (nonatomic, retain) IBOutlet NSTextField *label;
|
||||||
@property (nonatomic, retain) NSString *title;
|
@property (nonatomic, retain) NSString *title;
|
||||||
|
|
||||||
|
-(void)updateTitle;
|
||||||
|
|
||||||
-(void)fadeIn;
|
-(void)fadeIn;
|
||||||
-(void)fadeOut;
|
-(void)fadeOut;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
@implementation TitleBarView
|
@implementation TitleBarView
|
||||||
@synthesize label = _label;
|
@synthesize label = _label;
|
||||||
@synthesize color = _color;
|
@synthesize backgroundColor = _backgroundColor;
|
||||||
|
|
||||||
-(id)initWithFrame:(NSRect)frameRect
|
-(id)initWithFrame:(NSRect)frameRect
|
||||||
{
|
{
|
||||||
|
@ -40,29 +40,74 @@
|
||||||
|
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
|
[_backgroundColor release];
|
||||||
[_leftImage release];
|
[_leftImage release];
|
||||||
[_rightImage release];
|
[_rightImage release];
|
||||||
[_centerImage release];
|
[_centerImage release];
|
||||||
[_label release];
|
[_label release];
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)setBackgroundColor:(NSColor *)backgroundColor
|
||||||
|
{
|
||||||
|
|
||||||
|
NSColor *tmp;
|
||||||
|
|
||||||
|
if (_backgroundColor == backgroundColor) return;
|
||||||
|
|
||||||
|
[_backgroundColor release];
|
||||||
|
_backgroundColor = [backgroundColor retain];
|
||||||
|
|
||||||
|
|
||||||
|
_dark = YES;
|
||||||
|
|
||||||
|
tmp = [_backgroundColor colorUsingColorSpaceName: NSCalibratedWhiteColorSpace];
|
||||||
|
if (tmp)
|
||||||
|
{
|
||||||
|
if ([tmp whiteComponent] > 0.5) _dark = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self updateTitle];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTitle:(NSString *)title
|
-(void)setTitle:(NSString *)title
|
||||||
|
{
|
||||||
|
[_label setStringValue: title];
|
||||||
|
[self updateTitle];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSString *)title
|
||||||
|
{
|
||||||
|
return [_label stringValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-(void)updateTitle
|
||||||
{
|
{
|
||||||
NSAttributedString *as;
|
NSAttributedString *as;
|
||||||
NSDictionary *attr;
|
NSDictionary *attr;
|
||||||
NSShadow *shadow;
|
NSShadow *shadow;
|
||||||
NSMutableParagraphStyle *ps;
|
NSMutableParagraphStyle *ps;
|
||||||
|
|
||||||
if (!title)
|
|
||||||
|
NSString *title;
|
||||||
|
|
||||||
|
|
||||||
|
title = [_label stringValue];
|
||||||
|
|
||||||
|
|
||||||
|
if (![title length])
|
||||||
{
|
{
|
||||||
[_label setStringValue: @""];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[_label setTextColor: _dark ? [NSColor whiteColor] : [NSColor blackColor]];
|
||||||
|
|
||||||
shadow = [NSShadow new];
|
shadow = [NSShadow new];
|
||||||
[shadow setShadowBlurRadius: 1.0];
|
[shadow setShadowBlurRadius: 1.0];
|
||||||
[shadow setShadowColor: [NSColor blackColor]];
|
[shadow setShadowColor: _dark ? [NSColor blackColor] : [NSColor whiteColor]];
|
||||||
[shadow setShadowOffset: NSMakeSize(0.0, 1.0)];
|
[shadow setShadowOffset: _dark ? NSMakeSize(0.0, 1.0) : NSMakeSize(0.0, -1.0)];
|
||||||
|
|
||||||
ps = [NSMutableParagraphStyle new];
|
ps = [NSMutableParagraphStyle new];
|
||||||
[ps setAlignment: NSCenterTextAlignment];
|
[ps setAlignment: NSCenterTextAlignment];
|
||||||
|
@ -75,16 +120,13 @@
|
||||||
|
|
||||||
as = [[NSAttributedString alloc] initWithString: title attributes: attr];
|
as = [[NSAttributedString alloc] initWithString: title attributes: attr];
|
||||||
[_label setAttributedStringValue: as];
|
[_label setAttributedStringValue: as];
|
||||||
|
|
||||||
|
|
||||||
[as release];
|
[as release];
|
||||||
[shadow release];
|
[shadow release];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString *)title
|
|
||||||
{
|
|
||||||
return [_label stringValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)isFlipped
|
-(BOOL)isFlipped
|
||||||
|
@ -96,6 +138,7 @@
|
||||||
-(void)drawRect:(NSRect)dirtyRect
|
-(void)drawRect:(NSRect)dirtyRect
|
||||||
{
|
{
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
|
NSRect rect;
|
||||||
|
|
||||||
|
|
||||||
bounds = [self bounds];
|
bounds = [self bounds];
|
||||||
|
@ -107,10 +150,12 @@
|
||||||
[path addClip];
|
[path addClip];
|
||||||
|
|
||||||
|
|
||||||
[_color setFill];
|
[_backgroundColor setFill];
|
||||||
NSRectFill(dirtyRect);
|
NSRectFill(dirtyRect);
|
||||||
|
|
||||||
NSDrawThreePartImage(NSMakeRect(0, 0, bounds.size.width, 24.0),_leftImage, _centerImage, _rightImage, NO, NSCompositeSourceOver, 1.0, YES);
|
rect = NSMakeRect(0, 0, bounds.size.width, 24.0);
|
||||||
|
rect = NSInsetRect(rect, 1, 0);
|
||||||
|
NSDrawThreePartImage(rect, _leftImage, _centerImage, _rightImage, NO, NSCompositeSourceOver, 1.0, YES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user