public
Description: OS X: displays recent CPU usage in the Dock or a floating window
Homepage: http://cbowns.com/cpuhistory/
Clone URL: git://github.com/cbowns/cpu-history.git
Christopher Bowns (author)
Sun Nov 09 15:58:58 -0800 2008
commit  800185fe2bcb58bcb025ae6858b8819cf80c4bb2
tree    ce63aaa759b0150473c3ef2928fbc3ff6c35296b
parent  c80ed6d1e8ff6a7aa874e6fc0901fc0f93ce1246
cpu-history / TranslucentWindow.m
100644 62 lines (45 sloc) 1.647 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// TranslucentView.m
//
// Created by Takashi T. Hamada on Thu Nov 01 2000.
// Copyright (c) 2000,2001 Takashi T. Hamada. All rights reserved.
//
// Modifications:
// bb 26.06.2002 - removed the _transparency method
//
 
#import "TranslucentWindow.h"
 
 
@implementation TranslucentWindow
 
//-------------------------------------------------------------
// set the transparency
//-------------------------------------------------------------
//- (float)_transparency
//{
// return 0.9999999999;
//}
 
 
 
// Not much here, just calling the following private API.
extern void _NSSetWindowOpacity(int windowNumber, BOOL isOpaque);
 
 
//-------------------------------------------------------------
// make the window (pseudo) transparent
//-------------------------------------------------------------
- initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
    if (self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag])
        _NSSetWindowOpacity([self windowNumber], NO);
 
    [self setAcceptsMouseMovedEvents:YES]; // for dragging itself by receiving the mouse events
    
    return self;
}
 
 
//-------------------------------------------------------------
// no shadow is needed
//-------------------------------------------------------------
- (BOOL)hasShadow
{
    return NO;
}
 
 
//-------------------------------------------------------------
// For displaying the tooltips with transparent window
//-------------------------------------------------------------
- (BOOL)canBecomeKeyWindow
{
    return YES;
}
 
@end