update titlebar

git-svn-id: svn://qnap.local/TwoTerm/branches/frameless@2341 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2011-12-23 20:35:00 +00:00
parent f4b3ccecee
commit eede1abbca
10 changed files with 328 additions and 123 deletions

View File

@ -38,10 +38,11 @@
B61EF7C914815AF8008C1891 /* NewTerminal.xib in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7C714815AF8008C1891 /* NewTerminal.xib */; };
B61EF7CC14815E07008C1891 /* TitleBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = B61EF7CB14815E07008C1891 /* TitleBarView.m */; };
B61EF7CF148163E7008C1891 /* TitleBarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7CD148163E7008C1891 /* TitleBarView.xib */; };
B61EF7D71482FB6D008C1891 /* titlebar-center.png.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D41482FB6D008C1891 /* titlebar-center.png.png */; };
B61EF7D81482FB6D008C1891 /* titlebar-left.png.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D51482FB6D008C1891 /* titlebar-left.png.png */; };
B61EF7D91482FB6D008C1891 /* titlebar-right.png.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D61482FB6D008C1891 /* titlebar-right.png.png */; };
B61EF7D71482FB6D008C1891 /* titlebar-center.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D41482FB6D008C1891 /* titlebar-center.png */; };
B61EF7D81482FB6D008C1891 /* titlebar-left.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D51482FB6D008C1891 /* titlebar-left.png */; };
B61EF7D91482FB6D008C1891 /* titlebar-right.png in Resources */ = {isa = PBXBuildFile; fileRef = B61EF7D61482FB6D008C1891 /* titlebar-right.png */; };
B627333B12E3FF5B00A14C94 /* ChildMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = B627333A12E3FF5B00A14C94 /* ChildMonitor.m */; };
B638188214A179D60027D007 /* ColorView.m in Sources */ = {isa = PBXBuildFile; fileRef = B638188114A179D60027D007 /* ColorView.m */; };
B66412391480A070003BC8D3 /* EmulatorWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = B66412381480A070003BC8D3 /* EmulatorWindow.m */; };
B676063B11DEAD3500D6B66C /* TermWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B676063A11DEAD3500D6B66C /* TermWindowController.mm */; };
B676065111DEBAE900D6B66C /* TermWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = B676065011DEBAE900D6B66C /* TermWindow.xib */; };
@ -132,11 +133,13 @@
B61EF7CA14815E07008C1891 /* TitleBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TitleBarView.h; sourceTree = "<group>"; };
B61EF7CB14815E07008C1891 /* TitleBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TitleBarView.m; sourceTree = "<group>"; };
B61EF7CE148163E7008C1891 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/TitleBarView.xib; sourceTree = "<group>"; };
B61EF7D41482FB6D008C1891 /* titlebar-center.png.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-center.png.png"; sourceTree = "<group>"; };
B61EF7D51482FB6D008C1891 /* titlebar-left.png.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-left.png.png"; sourceTree = "<group>"; };
B61EF7D61482FB6D008C1891 /* titlebar-right.png.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-right.png.png"; sourceTree = "<group>"; };
B61EF7D41482FB6D008C1891 /* titlebar-center.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-center.png"; sourceTree = "<group>"; };
B61EF7D51482FB6D008C1891 /* titlebar-left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-left.png"; sourceTree = "<group>"; };
B61EF7D61482FB6D008C1891 /* titlebar-right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "titlebar-right.png"; sourceTree = "<group>"; };
B627333912E3FF5B00A14C94 /* ChildMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildMonitor.h; sourceTree = "<group>"; };
B627333A12E3FF5B00A14C94 /* ChildMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChildMonitor.m; sourceTree = "<group>"; };
B638188014A179D60027D007 /* ColorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorView.h; sourceTree = "<group>"; };
B638188114A179D60027D007 /* ColorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorView.m; sourceTree = "<group>"; };
B66412371480A070003BC8D3 /* EmulatorWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmulatorWindow.h; sourceTree = "<group>"; };
B66412381480A070003BC8D3 /* EmulatorWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EmulatorWindow.m; sourceTree = "<group>"; };
B676063911DEAD3500D6B66C /* TermWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TermWindowController.h; sourceTree = "<group>"; };
@ -301,9 +304,9 @@
B612F46B12DD5E02005D1B77 /* Views */ = {
isa = PBXGroup;
children = (
B68E632812FF909C00EAFF5F /* ExampleView.h */,
B66412371480A070003BC8D3 /* EmulatorWindow.h */,
B66412381480A070003BC8D3 /* EmulatorWindow.m */,
B68E632812FF909C00EAFF5F /* ExampleView.h */,
B68E632912FF909C00EAFF5F /* ExampleView.m */,
B612F46C12DD5E02005D1B77 /* CurveView.h */,
B612F46D12DD5E02005D1B77 /* CurveView.m */,
@ -313,6 +316,8 @@
B612870D1480B4F6002E04DF /* TermContentView.m */,
B61EF7CA14815E07008C1891 /* TitleBarView.h */,
B61EF7CB14815E07008C1891 /* TitleBarView.m */,
B638188014A179D60027D007 /* ColorView.h */,
B638188114A179D60027D007 /* ColorView.m */,
);
path = Views;
sourceTree = "<group>";
@ -320,9 +325,9 @@
B66979CE11E6BCAE002ED475 /* images */ = {
isa = PBXGroup;
children = (
B61EF7D41482FB6D008C1891 /* titlebar-center.png.png */,
B61EF7D51482FB6D008C1891 /* titlebar-left.png.png */,
B61EF7D61482FB6D008C1891 /* titlebar-right.png.png */,
B61EF7D41482FB6D008C1891 /* titlebar-center.png */,
B61EF7D51482FB6D008C1891 /* titlebar-left.png */,
B61EF7D61482FB6D008C1891 /* titlebar-right.png */,
B61EF7C31481561E008C1891 /* titlebar-corner.png */,
B61EF7C41481561E008C1891 /* titlebar-middle.png */,
B6801BD812EB549300B22E9E /* vt100-charset.png */,
@ -396,9 +401,9 @@
B61EF7C61481561E008C1891 /* titlebar-middle.png in Resources */,
B61EF7C914815AF8008C1891 /* NewTerminal.xib in Resources */,
B61EF7CF148163E7008C1891 /* TitleBarView.xib in Resources */,
B61EF7D71482FB6D008C1891 /* titlebar-center.png.png in Resources */,
B61EF7D81482FB6D008C1891 /* titlebar-left.png.png in Resources */,
B61EF7D91482FB6D008C1891 /* titlebar-right.png.png in Resources */,
B61EF7D71482FB6D008C1891 /* titlebar-center.png in Resources */,
B61EF7D81482FB6D008C1891 /* titlebar-left.png in Resources */,
B61EF7D91482FB6D008C1891 /* titlebar-right.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -436,6 +441,7 @@
B66412391480A070003BC8D3 /* EmulatorWindow.m in Sources */,
B612870E1480B4F6002E04DF /* TermContentView.m in Sources */,
B61EF7CC14815E07008C1891 /* TitleBarView.m in Sources */,
B638188214A179D60027D007 /* ColorView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -39,7 +39,7 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowStyleMask">271</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{158, 575}, {600, 424}}</string>
<int key="NSWTFlags">539492352</int>
@ -58,56 +58,6 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomView" id="749660088">
<reference key="NSNextResponder" ref="1067446494"/>
<int key="NSvFlags">4362</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTextField" id="777714454">
<reference key="NSNextResponder" ref="749660088"/>
<int key="NSvFlags">298</int>
<string key="NSFrame">{{150, 4}, {300, 17}}</string>
<reference key="NSSuperview" ref="749660088"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="59249513"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSReuseIdentifierKey">_NS:3944</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="941354338">
<int key="NSCellFlags">67239488</int>
<int key="NSCellFlags2">138418176</int>
<string key="NSContents">Label</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:3944</string>
<reference key="NSControlView" ref="777714454"/>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
</object>
</object>
<string key="NSFrame">{{0, 400}, {600, 24}}</string>
<reference key="NSSuperview" ref="1067446494"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="777714454"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSReuseIdentifierKey">_NS:1192</string>
<string key="NSClassName">TitleBarView</string>
</object>
<object class="NSCustomView" id="59249513">
<reference key="NSNextResponder" ref="1067446494"/>
<int key="NSvFlags">274</int>
@ -122,9 +72,9 @@
<string key="NSFrameSize">{600, 424}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="749660088"/>
<reference key="NSNextKeyView" ref="59249513"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSClassName">CurveView</string>
<string key="NSClassName">ColorView</string>
</object>
</object>
<string key="NSFrameSize">{600, 424}</string>
@ -139,6 +89,56 @@
<int key="NSWindowCollectionBehavior">128</int>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
<object class="NSCustomView" id="1044168626">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTextField" id="301482921">
<reference key="NSNextResponder" ref="1044168626"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{75, 2}, {250, 17}}</string>
<reference key="NSSuperview" ref="1044168626"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSReuseIdentifierKey">_NS:3944</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="821760182">
<int key="NSCellFlags">67239488</int>
<int key="NSCellFlags2">138450944</int>
<string key="NSContents">Label</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande-Bold</string>
<double key="NSSize">13</double>
<int key="NSfFlags">2072</int>
</object>
<string key="NSCellIdentifier">_NS:3944</string>
<reference key="NSControlView" ref="301482921"/>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAwIDAAA</bytes>
</object>
</object>
</object>
</object>
<string key="NSFrameSize">{400, 24}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="301482921"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSReuseIdentifierKey">_NS:1192</string>
<string key="NSClassName">TitleBarView</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@ -197,19 +197,19 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">titleBar</string>
<reference key="source" ref="1006"/>
<reference key="destination" ref="749660088"/>
<string key="label">titleBarView</string>
<reference key="source" ref="1005"/>
<reference key="destination" ref="1044168626"/>
</object>
<int key="connectionID">25</int>
<int key="connectionID">29</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">label</string>
<reference key="source" ref="749660088"/>
<reference key="destination" ref="777714454"/>
<reference key="source" ref="1044168626"/>
<reference key="destination" ref="301482921"/>
</object>
<int key="connectionID">24</int>
<int key="connectionID">33</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@ -265,7 +265,6 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="59249513"/>
<reference ref="749660088"/>
</object>
<reference key="parent" ref="1006"/>
</object>
@ -276,27 +275,27 @@
<string key="objectName">Emulator View</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">21</int>
<reference key="object" ref="749660088"/>
<int key="objectID">28</int>
<reference key="object" ref="1044168626"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="777714454"/>
<reference ref="301482921"/>
</object>
<reference key="parent" ref="1067446494"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">22</int>
<reference key="object" ref="777714454"/>
<int key="objectID">30</int>
<reference key="object" ref="301482921"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="941354338"/>
<reference ref="821760182"/>
</object>
<reference key="parent" ref="749660088"/>
<reference key="parent" ref="1044168626"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">23</int>
<reference key="object" ref="941354338"/>
<reference key="parent" ref="777714454"/>
<int key="objectID">31</int>
<reference key="object" ref="821760182"/>
<reference key="parent" ref="301482921"/>
</object>
</object>
</object>
@ -312,9 +311,13 @@
<string>1.NSWindowTemplate.visibleAtLaunch</string>
<string>2.CustomClassName</string>
<string>2.IBPluginDependency</string>
<string>21.IBPluginDependency</string>
<string>22.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
<string>28.IBPluginDependency</string>
<string>30.IBPluginDependency</string>
<string>30.IBViewIntegration.shadowBlurRadius</string>
<string>30.IBViewIntegration.shadowColor</string>
<string>30.IBViewIntegration.shadowOffsetHeight</string>
<string>30.IBViewIntegration.shadowOffsetWidth</string>
<string>31.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
@ -330,6 +333,13 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<real value="0.0"/>
<object class="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
<real value="1"/>
<real value="0.0"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -347,7 +357,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">27</int>
<int key="maxID">35</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -360,6 +370,14 @@
<string key="minorKey">./Classes/ChildMonitor.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ColorView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/ColorView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">CurveView</string>
<string key="superclassName">NSView</string>
@ -411,6 +429,17 @@
<object class="IBPartialClassDescription">
<string key="className">EmulatorWindow</string>
<string key="superclassName">NSWindow</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">titleBarView</string>
<string key="NS.object.0">TitleBarView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">titleBarView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">titleBarView</string>
<string key="candidateClassName">TitleBarView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/EmulatorWindow.h</string>

View File

@ -237,6 +237,7 @@
_emulator = [klass new];
[self didChangeValueForKey: @"emulator"];
[window setBackgroundColor: backgroundColor];
[_emulatorView setEmulator: _emulator];
[_emulatorView setForegroundColor: foregroundColor];

18
Views/ColorView.h Normal file
View File

@ -0,0 +1,18 @@
//
// ColorView.h
// 2Term
//
// Created by Kelvin Sherlock on 12/20/2011.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface ColorView : NSView
{
NSColor *_color;
}
@property (nonatomic, retain) NSColor *color;
@end

35
Views/ColorView.m Normal file
View File

@ -0,0 +1,35 @@
//
// ColorView.m
// 2Term
//
// Created by Kelvin Sherlock on 12/20/2011.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "ColorView.h"
@implementation ColorView
@synthesize color = _color;
- (void)drawRect:(NSRect)dirtyRect
{
[_color setFill];
NSRectFill(dirtyRect);
}
-(void)setColor:(NSColor *)color
{
if (_color == color) return;
[_color release];
_color = [color retain];
[self setNeedsDisplay: YES];
}
-(void)dealloc
{
[_color release];
[super dealloc];
}
@end

View File

@ -7,9 +7,16 @@
//
#import <AppKit/AppKit.h>
@class TitleBarView;
@interface EmulatorWindow : NSWindow
{
TitleBarView *_titleBarView;
}
@property (nonatomic, retain) IBOutlet TitleBarView *titleBarView;
-(void)adjustTitleBar;
@end

View File

@ -7,17 +7,20 @@
//
#import "EmulatorWindow.h"
#import "TitleBarView.h"
@implementation EmulatorWindow
@synthesize titleBarView = _titleBarView;
-(id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
{
if ((self = [super initWithContentRect: contentRect
styleMask: NSBorderlessWindowMask
styleMask: styleMask
backing: bufferingType
defer: flag]))
{
@ -29,6 +32,7 @@
[self setResizeIncrements: NSMakeSize(1.0, 2.0)];
[self setMovableByWindowBackground: YES];
//[self setBackgroundColor: [NSColor clearColor]];
//[self setHasShadow: NO];
//[self setHasShadow: YES];
@ -38,15 +42,16 @@
return self;
}
-(id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
screen:(NSScreen *)screen
{
if ((self = [super initWithContentRect: contentRect
styleMask: NSBorderlessWindowMask | NSResizableWindowMask
styleMask: styleMask
backing: bufferingType
defer: flag
screen: screen]))
@ -67,12 +72,33 @@
}
-(void)awakeFromNib
-(void)dealloc
{
[NSApp addWindowsItem: self title: @"Window Title" filename: NO];
//[self setHasShadow: YES];
[_titleBarView release];
[super dealloc];
}
-(void)setTitle:(NSString *)aString
{
[super setTitle: aString];
[_titleBarView setTitle: aString];
}
-(void)setBackgroundColor:(NSColor *)color
{
NSLog(@"%@", color);
[super setBackgroundColor: color];
[_titleBarView setColor: color];
}
-(void)awakeFromNib
{
[self adjustTitleBar];
//[NSApp addWindowsItem: self title: @"Window Title" filename: NO];
//[self setHasShadow: YES];
}
/*
-(BOOL)canBecomeKeyWindow {
return YES;
}
@ -84,7 +110,40 @@
-(BOOL)isExcludedFromWindowsMenu {
return NO;
}
*/
-(void)adjustTitleBar
{
NSView *themeView;
NSArray *array;
themeView = [[self contentView] superview];
NSLog(@"%@", themeView);
NSLog(@"%u", (int)[_titleBarView retainCount]);
[_titleBarView setColor: [NSColor blackColor]];
[_titleBarView setFrame: [themeView bounds]];
[_titleBarView setTitle: [self title]];
NSLog(@"%@", [self title]);
array = [themeView subviews];
NSLog(@"%@", array);
[themeView addSubview: _titleBarView
positioned: NSWindowBelow
relativeTo: [array objectAtIndex: 0]];
array = [themeView subviews];
NSLog(@"%@", array);
}
@end

View File

@ -14,6 +14,9 @@
-(void)createTrackingArea
{
return;
NSRect rect;
NSRect bounds;
@ -46,11 +49,13 @@
}
-(void)updateTrackingAreas
{
[self createTrackingArea];
}
-(void)dealloc
{
[_trackingArea release];
@ -58,7 +63,7 @@
[super dealloc];
}
/*
-(void)mouseEntered:(NSEvent *)theEvent
{
//NSLog(@"%s", sel_getName(_cmd));
@ -74,5 +79,6 @@
[_titleBar fadeOut];
// animate title bar out.
}
*/
@end

View File

@ -10,14 +10,16 @@
@interface TitleBarView : NSView
{
NSColor *_color;
NSTextField *_label;
NSImage *_rightImage;
NSImage *_leftImage;
NSImage *_centerImage;
}
@property (nonatomic, assign) IBOutlet NSTextField *label;
@property (nonatomic, assign) NSString *title;
@property (nonatomic, retain) NSColor *color;
@property (nonatomic, retain) IBOutlet NSTextField *label;
@property (nonatomic, retain) NSString *title;
-(void)fadeIn;
-(void)fadeOut;

View File

@ -12,19 +12,30 @@
@implementation TitleBarView
@synthesize label = _label;
@synthesize color = _color;
-(id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame: frameRect]))
{
[self setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[self awakeFromNib];
}
return self;
}
-(void)awakeFromNib
{
[_label setTextColor: [NSColor whiteColor]];
[self setContentFilters: [NSArray array]];
{
_leftImage = [[NSImage imageNamed: @"titlebar-left.png"] retain];
_rightImage = [[NSImage imageNamed: @"titlebar-right.png"] retain];
_centerImage = [[NSImage imageNamed: @"titlebar-center.png"] retain];
[self setWantsLayer: YES];
[[self layer] setOpacity: 0.0];
[_label setStringValue: @""];
[_label setBackgroundColor: [NSColor clearColor]];
[_label setTextColor: [NSColor whiteColor]];
}
-(void)dealloc
@ -37,7 +48,37 @@
-(void)setTitle:(NSString *)title
{
[_label setStringValue: title];
NSAttributedString *as;
NSDictionary *attr;
NSShadow *shadow;
NSMutableParagraphStyle *ps;
if (!title)
{
[_label setStringValue: @""];
return;
}
shadow = [NSShadow new];
[shadow setShadowBlurRadius: 1.0];
[shadow setShadowColor: [NSColor blackColor]];
[shadow setShadowOffset: NSMakeSize(0.0, 1.0)];
ps = [NSMutableParagraphStyle new];
[ps setAlignment: NSCenterTextAlignment];
[ps setLineBreakMode: NSLineBreakByTruncatingMiddle];
attr = [NSDictionary dictionaryWithObjectsAndKeys:
shadow, NSShadowAttributeName,
ps, NSParagraphStyleAttributeName,
nil];
as = [[NSAttributedString alloc] initWithString: title attributes: attr];
[_label setAttributedStringValue: as];
[as release];
[shadow release];
}
-(NSString *)title
@ -45,31 +86,32 @@
return [_label stringValue];
}
-(BOOL)isFlipped
{
return YES;
}
-(void)drawRect:(NSRect)dirtyRect
{
NSRect bounds;
NSRect rect;
bounds = [self bounds];
/*
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0, 0, bounds.size.width, bounds.size.height * 2)
xRadius: 5.0 yRadius: 5.0];
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0, 0, bounds.size.width, bounds.size.height)
xRadius: 4.0
yRadius: 4.0];
[path addClip];
*/
rect = NSMakeRect(0, 0, 10, 24);
if (NSIntersectsRect(rect, dirtyRect))
[_leftImage drawInRect: rect fromRect: NSMakeRect(0, 0, 10, 24) operation: NSCompositeSourceOver fraction: 1.0];
[_color setFill];
NSRectFill(dirtyRect);
NSDrawThreePartImage(NSMakeRect(0, 0, bounds.size.width, 24.0),_leftImage, _centerImage, _rightImage, NO, NSCompositeSourceOver, 1.0, YES);
rect = NSMakeRect(bounds.size.width - 10, 0, 10, 24);
if (NSIntersectsRect(rect, dirtyRect))
[_rightImage drawInRect: rect fromRect: NSMakeRect(0, 0, 10, 24) operation: NSCompositeSourceOver fraction: 1.0];
bounds = NSInsetRect(bounds, 10, 0);
[_centerImage drawInRect: bounds fromRect:NSMakeRect(0, 0, 1, 24) operation: NSCompositeSourceOver fraction: 1.0];
}
-(void)fadeIn