Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (82 sloc) 3.169 kb
dc5be1c Initial check-in.
uli authored
1 //
2 // UKWindowBodyView.m
3 // ValueConverter
4 //
5 // Created by Uli Kusterer on 26.04.08.
720b0e7 @uliwitness Added licensing information to the source files.
authored
6 // Copyright 2008 Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
dc5be1c Initial check-in.
uli authored
26 //
27
5344702 Changes to ValueConverter before 1.3 release.
uli authored
28 // -----------------------------------------------------------------------------
29 // Headers:
30 // -----------------------------------------------------------------------------
31
dc5be1c Initial check-in.
uli authored
32 #import "UKWindowBodyView.h"
33 #import <Carbon/Carbon.h>
34
35
36 @implementation UKWindowBodyView
37
38 - (id)initWithFrame:(NSRect)frame
39 {
40 self = [super initWithFrame:frame];
41 if (self)
42 {
43 // Initialization code here.
44 }
45 return self;
46 }
47
48 -(void) changeGradientsOfWindow: (NSWindow*)eswin
49 {
50 if( [eswin respondsToSelector: @selector(setContentBorderThickness:forEdge:)] )
51 {
52 if( [eswin styleMask] & NSTexturedBackgroundWindowMask ) // Can't set top edge of non-textured windows as of 10.5.2.
53 {
54 [eswin setAutorecalculatesContentBorderThickness: NO forEdge:NSMaxYEdge];
55 float desiredTopBorderHeight = [[eswin contentView] bounds].size.height -NSMaxY([self frame]);
56 [eswin setContentBorderThickness: desiredTopBorderHeight forEdge: NSMaxYEdge];
57 }
58
59 [eswin setAutorecalculatesContentBorderThickness: NO forEdge: NSMinYEdge];
60 float desiredBottomBorderHeight = NSMinY([self frame]);
61 [eswin setContentBorderThickness: desiredBottomBorderHeight forEdge: NSMinYEdge];
62 }
63 }
64
65 -(void) viewWillMoveToSuperview: (NSView *)newSuperview
66 {
67 [self changeGradientsOfWindow: [newSuperview window]];
68 }
69
70 -(void) viewWillMoveToWindow: (NSWindow *)newWindow
71 {
72 [self changeGradientsOfWindow: newWindow];
73 }
74
75 -(void) awakeFromNib
76 {
77 [self changeGradientsOfWindow: [self window]];
78 }
79
80 -(void) drawRect: (NSRect)rect
81 {
82 BOOL isActive = [[self window] isMainWindow];
83 NSRect box = [self bounds];
84
85 HIThemeSetFill( isActive ? kThemeBrushModelessDialogBackgroundActive : kThemeBrushModelessDialogBackgroundInactive,
86 NULL, [[NSGraphicsContext currentContext] graphicsPort], kHIThemeOrientationInverted );
87 NSRectFill( box );
88
89 box.origin.y += 1; box.size.height -= 1;
90 [[NSColor colorWithCalibratedWhite: isActive? 0.3 : 0.5 alpha: 1.0] set];
91 NSFrameRectWithWidth( box, 1 );
92
93 [[NSColor colorWithCalibratedWhite: 0.9 alpha: 0.8] set];
94 [NSBezierPath strokeLineFromPoint: NSMakePoint(box.origin.x,box.origin.y -1) toPoint: NSMakePoint(NSMaxX(box),box.origin.y -1)];
95 }
96
97 @end
Something went wrong with that request. Please try again.